package com.gaohe.web.controller.scp;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gaohe.common.annotation.Log;
import com.gaohe.common.core.controller.BaseController;
import com.gaohe.common.core.domain.AjaxResult;
import com.gaohe.common.enums.BusinessType;
import com.gaohe.scp.domain.CsCarExplain;
import com.gaohe.scp.service.ICsCarExplainService;
import com.gaohe.common.utils.poi.ExcelUtil;
import com.gaohe.common.core.page.TableDataInfo;

/**
 * 车辆成交说明Controller
 *
 * @author liuxiangyu
 * @date 2025-03-25
 */
@RestController
@RequestMapping("/scp/explain")
public class CsCarExplainController extends BaseController
{
    @Autowired
    private ICsCarExplainService csCarExplainService;

    // 通过carId查询车辆成交说明---牛相善
//    @PreAuthorize("@ss.hasPermi('scp:explain:query')")
    @GetMapping(value = "/car/{carId}")
    public AjaxResult getExplainByCarId(@PathVariable("carId") Long carId)
    {
        return success(csCarExplainService.selectCsCarExplainByCarId(carId));
    }
    /**
     * 查询车辆成交说明列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CsCarExplain csCarExplain)
    {
        startPage();
        List<CsCarExplain> list = csCarExplainService.selectCsCarExplainList(csCarExplain);
        return getDataTable(list);
    }

    /**
     * 导出车辆成交说明列表
     */
    @Log(title = "车辆成交说明", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CsCarExplain csCarExplain)
    {
        List<CsCarExplain> list = csCarExplainService.selectCsCarExplainList(csCarExplain);
        ExcelUtil<CsCarExplain> util = new ExcelUtil<CsCarExplain>(CsCarExplain.class);
        util.exportExcel(response, list, "车辆成交说明数据");
    }

    /**
     * 获取车辆成交说明详细信息
     */
    @GetMapping(value = "/{explainId}")
    public AjaxResult getInfo(@PathVariable("explainId") Long explainId)
    {
        return success(csCarExplainService.selectCsCarExplainByExplainId(explainId));
    }

    /**
     * 新增车辆成交说明
     */
//    @PreAuthorize("@ss.hasPermi('scp:explain:add')")
    @Log(title = "车辆成交说明", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CsCarExplain csCarExplain)
    {
        return toAjax(csCarExplainService.insertCsCarExplain(csCarExplain));
    }

    /**
     * 修改车辆成交说明
     */
//    @PreAuthorize("@ss.hasPermi('scp:explain:edit')")
    @Log(title = "车辆成交说明", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CsCarExplain csCarExplain)
    {
        return toAjax(csCarExplainService.updateCsCarExplain(csCarExplain));
    }

    /**
     * 删除车辆成交说明
     */
//    @PreAuthorize("@ss.hasPermi('scp:explain:remove')")
    @Log(title = "车辆成交说明", businessType = BusinessType.DELETE)
	@DeleteMapping("/{explainIds}")
    public AjaxResult remove(@PathVariable Long[] explainIds)
    {
        return toAjax(csCarExplainService.deleteCsCarExplainByExplainIds(explainIds));
    }
}
